/*
 * File: plook_u32u8u16_bincka.c
 *
 * Code generated for Simulink model 'SOCE'.
 *
 * Model version                  : 3.270
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Mon Apr  3 13:38:00 2023
 */

#include "rtwtypes.h"
#include "binsearch_u32u16.h"
#include "plook_u32u8u16_bincka.h"

uint32_T plook_u32u8u16_bincka(uint8_T u, const uint16_T bp[], uint32_T maxIndex)
{
    uint32_T bpIndex;

    /* Prelookup - Index only
       Index Search method: 'binary'
       Extrapolation method: 'Clip'
       Use previous index: 'off'
       Use last breakpoint for index at or above upper limit: 'on'
       Remove protection against out-of-range input in generated code: 'off'
     */
    if (u < bp[0U])
    {
        bpIndex = 0U;
    }
    else if (u < bp[maxIndex])
    {
        bpIndex = binsearch_u32u16(u, bp, maxIndex >> 1U, maxIndex);
    }
    else
    {
        bpIndex = maxIndex;
    }

    return bpIndex;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */

